package com.fxz.edu.ad.controller;

import com.fxz.edu.dto.PromotionSpaceDTO;
import com.fxz.edu.remote.AdRemoteService;
import com.fxz.edu.response.ResponseDTO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Fxz
 * @version 1.0
 * @date 2021-08-30 15:56
 */
@AllArgsConstructor
@RequestMapping("/ad")
@RestController
public class AdController {

    private final AdRemoteService adRemoteService;

    /**
     * 前台通过spaceKey获取广告位以及广告信息
     *
     * @param spaceKey
     * @return
     */
    @GetMapping("/getAdBySpaceKey")
    public ResponseDTO getAdBySpaceKey(@RequestParam("spaceKey") String[] spaceKey) {
        List<PromotionSpaceDTO> adBySpaceKey = adRemoteService.getAdBySpaceKey(spaceKey);
        return ResponseDTO.success(adBySpaceKey);
    }

}
